<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@include file="/WEB-INF/view/common/common.jsp" %>
<style>
    <!--
    -->
    .none {
        display: none;
    }
</style>
<div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
        <div class="modal-header bg-primary">
            <button type="button" class="close" data-dismiss="modal"
                    aria-label="Close">
                <span aria-hidden="true">&times;</span>
            </button>
            <h4 class="modal-title" id="myModalLabel">提现记录</h4>
        </div>
        <div class="modal-body">
            <div class="container-fluid">
                <div class="row">
                    <form action="<c:url value='/cash/edit.json'/>" name="editForm"
                          class="form-horizontal" id="editForm" method="post">
                        <ul class="nav nav-tabs" role="tablist">
                            <li role="presentation" class="active"><a href="#basicInfo" aria-controls="basicInfo"
                                                                      role="tab" data-toggle="tab">审核处理</a></li>
                        </ul>
                        <div class="tab-content">
                            <div role="tabpanel" class="tab-pane active" id="basicInfo">
                                <div class="col-md-12 col-xs-12">
                                    <div class="form-group">
                                        <input type="hidden" name="id" value="${parameter.entity.id}">
                                        <label for="status" class="col-sm-2 control-label">是否通过</label>
                                        <div class="col-sm-4">
                                        <select class="form-control" name="status" id="status">
                                        <c:choose>
                                        <c:when test="${parameter.entity.status ==0}">
                                        <option value="1" selected>通过</option>
                                        <option value="2">不通过</option>
                                        </c:when>
                                        <c:otherwise>
                                        <option value="1">通过</option>
                                        <option value="2">不通过</option>
                                        </c:otherwise>
                                        </c:choose>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <div class="form-group">
                <div class="col-md-6 col-xs-12">
                    <button type="button" class="btn btn-default btn-block quitBtn"
                            tabIndex="26" id="quitBtn" data-dismiss="modal" name="quitBtn"
                            value="login" tabindex="4" data-loading-text="正在返回......">
                        <span class="glyphicon glyphicon-remove-sign">&nbsp;</span>关闭
                    </button>
                </div>
                <div class="col-md-6 col-xs-12">
                    <button type="button" class="btn btn-primary btn-block"
                            form="editForm" tabIndex="27" id="saveBtn" name="saveBtn"
                            value="saveBtn" tabindex="4" data-loading-text="正在提交......">
                        <span class="glyphicon glyphicon-save">&nbsp;</span>确认
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>


<jsp:include page="/WEB-INF/view/common/form.jsp"></jsp:include>
<jsp:include page="/WEB-INF/view/common/script_common.jsp"></jsp:include>


<script type="text/javascript">
    $(function () {
        init();
    });
    function init() {
        $("#editName").focus().select();
        $("#editTeqName").focus().select();
        var btn = null;
        var langUrl = "<c:url value='/resources/js/datatables-plugins/i18n/Chinese.json'/>";

        $("#searchDT").click(function (e) {
            dt.draw();
        });
        $("#editForm")
            .validate(
                {
                    submitHandler: function (form) {
                        $(form)
                            .ajaxSubmit(
                                {
                                    beforeSubmit: function (arr, $form, options) {
                                        btn.button("loading");
                                    },
                                    success: function (responseText,
                                                       statusText, xhr,
                                                       $form) {
                                        var m = $
                                            .parseJSON(xhr.responseText);
                                        btn.button("reset");
                                        if (m.flag == "0") {
                                            alert("成功");
                                            $(".quitBtn")
                                                .click();
                                            location.reload();
                                        } else {
                                            alert("失败" + m.message);
                                        }

                                    },
                                    error: function (xhr,
                                                     textStatus,
                                                     errorThrown) {
                                        btn.button("reset");
                                        alert("失败");
                                        var m = $
                                            .parseJSON(xhr.responseText);

                                    }
                                });
                    },
                    rules: {


                    },
                    onkeyup: false,
                    messages: {



                    },
                    focusInvalid: true,
                    errorClass: "text-danger",
                    validClass: "valid",
                    errorElement: "small",
                    errorPlacement: function (error, element) {
                        error.appendTo(element
                            .closest("div.form-group").children(
                                "div.text-error"));
                    }
                });
        $("#editForm").find("input[type='checkbox']").change(function (e) {
            var $t = $(this);
            var next = $t.next("input[type='hidden']");
            alert(netx.val());
            $t.prop("checked") ? next.val(1) : next.val(0);
        });
        $("#saveBtn").click(function (e) {
            btn = $(this).button();
            $(document.forms["editForm"]).submit();
        });
        $("#removeAuthBtn").click(function (e) {
            $(this).closest("tr").remove();
        });
        $("a.ajaxLink.removeAuthBtn").click(function (e) {
            e.preventDefault();
            e.stopPropagation();
            var method = "DELETE";
            if (!window.confirm("确定取消本授权?")) {
                return false;
            }
            var dataRow = $(this).parents("TR");
            $.ajax({
                url: $(e.target).attr("href"), method: method, complete: function (xhr, ts) {
                    if (xhr.status >= 200 && xhr.status < 300) {
                        $("#alertMessageBody").empty().html("取消产品授权操作成功");
                        $("#myAlertModal").modal({backdrop: "static", show: true});
                        dataRow.remove();
                    } else {
                        $("#alertMessageBody").empty().html("取消产品授权操作失败").addClass("text-danger");
                        $("#myAlertModal").modal({backdrop: "static", show: true});
                    }
                }
            });
        });
        $('a[data-toggle="tab"]').on("show.bs.tab", function (e) {
        });
    }
</script>
